﻿using System.Collections.Generic;

namespace ConnectedComponents
{
    public class ConnectedComponent
    {
        public ConnectedComponent()
        {
            Spans = new SpanList();
            FrontalSpans = new SpanList();
            NewFrontalSpans = new SpanList();
        }

        public SpanList NewFrontalSpans { get; set; }
        public SpanList FrontalSpans { get; set; }
        public SpanList Spans { get; set; }

        public void UnionWith(ConnectedComponent connectedComponent)
        {
            Spans.UnionWith(connectedComponent.Spans);
            FrontalSpans.UnionWith(connectedComponent.FrontalSpans);
            NewFrontalSpans.UnionWith(connectedComponent.NewFrontalSpans);
        }
    }

    public class ConnectedComponentSet : List<ConnectedComponent>
    {
        public void AddNewComponentFromSpan(Span span)
        {
            ConnectedComponent newComponent = new ConnectedComponent();
            newComponent.NewFrontalSpans.Add(span);
            Add(newComponent);
        }
    }
}
